package nc.ui.ep.dj.controller;

import java.util.ArrayList;
import nc.impl.arap.proxy.Proxy;
import nc.itf.arap.prv.IArapBillPrivate;
import nc.ui.arap.pubdj.ArapDjPanel;
import nc.ui.arap.pubdj.PubDjPanel;
import nc.ui.arap.selectedpay.MainPanel;
import nc.ui.ep.dj.DjBasePanel;
import nc.ui.ep.dj.DjPanel;
import nc.ui.pub.ClientEnvironment;
import nc.ui.pub.pf.PfUtilClient;
import nc.vo.ep.dj.DJZBHeaderVO;
import nc.vo.ep.dj.DJZBItemVO;
import nc.vo.ep.dj.DJZBVO;
import nc.vo.pub.lang.UFDateTime;

public class ARAPDjCtlDjEditNor extends ARAPDjCtlDjEdit
{
  private MainPanel mainPanel;

  public ARAPDjCtlDjEditNor(PubDjPanel pubDjPanel, ArapDjPanel arapDjPanel)
  {
    super(pubDjPanel, arapDjPanel);
  }

  public ARAPDjCtlDjEditNor(DjPanel djPanel, ArapDjPanel arapDjPanel)
  {
    super(djPanel, arapDjPanel);
  }

  public ARAPDjCtlDjEditNor(MainPanel djPanel, ArapDjPanel arapDjPanel)
  {
    super((DjPanel)null, arapDjPanel);
    this.mainPanel = djPanel;
  }

  protected DJZBVO doBsSaveAction(DJZBVO djzbvo)
    throws Exception
  {
    String serverTime = ClientEnvironment.getServerTime().toString();
    String currTime = ClientEnvironment.getInstance().getDate() + serverTime.substring(10);

    ArrayList a1 = (ArrayList)PfUtilClient.processAction("SAVE", ((DJZBHeaderVO)djzbvo.getParentVO()).getDjlxbm(), currTime, djzbvo);

    return (DJZBVO)a1.get(1);
  }

  protected DJZBVO doBsEditAction(DJZBVO djzbvo)
    throws Exception
  {
    DJZBHeaderVO headvo = (DJZBHeaderVO)djzbvo.getParentVO();
    String serverTime = ClientEnvironment.getServerTime().toString();
    String currTime = ClientEnvironment.getInstance().getDate() + serverTime.substring(10);
    headvo.setShr(null);
    headvo.setShrq(null);
    headvo.setSpzt(null);
    if (djzbvo.m_isQr) {
      ArrayList a1 = (ArrayList)PfUtilClient.processAction("SAVE", headvo.getDjlxbm(), currTime, djzbvo);
      return (DJZBVO)a1.get(1);
    }

    return (DJZBVO)PfUtilClient.processAction("EDIT", headvo.getDjlxbm(), currTime, djzbvo);
  }

  protected DJZBItemVO[] doBsQueryItemAction(String djzboid)
    throws Exception
  {
    return Proxy.getIArapBillPrivate().queryDjzbitems(djzboid);
  }

  protected void showErrorMessage(String err)
  {
    if (this.m_parent != null)
      this.m_parent.showErrorMessage(err);
    else if (this.mainPanel != null)
      this.mainPanel.showErrorMessage(err);
  }

  protected void showHintMessage(String hint)
  {
    if (this.m_parent != null)
      this.m_parent.showHintMessage(hint);
    else if (this.mainPanel != null)
      this.mainPanel.showHintMessage(hint);
  }

  protected void showWarningMessage(String msg)
  {
    if (this.m_parent != null)
      this.m_parent.showWarningMessage(msg);
    else if (this.mainPanel != null)
      this.mainPanel.showWarningMessage(msg);
  }
}